﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Betop.Lib.Core.Base;

namespace Betop.Lib.Core.Company
{
    public class CompanyDAL : BaseDAL
    {
        public CompanyDAL()
        {
        }

        public CompanyInfo GetInfoByUrl(string url)
        {
            string sql = "select * from Company where SiteDomain like @p0";
            List<CompanyInfo> list = dbOper.Query<CompanyInfo>(sql, "%" + url + "%");
            if (list.Count > 0)
            {
                return list.First();
            }
            else
            {
                return null;
            }
        }

        public string GetPagerCondition(string input)
        {
            string condition = "";
            if (!string.IsNullOrEmpty(input))
            {
                condition = " Name like @p0 or SiteDomain like @p0";
            }
            return condition;
        }

        public CompanyInfo GetInfoByLoginName(string companyLoginName)
        {
            string sql = "select * from Company where LoginName=@p0";
            List<CompanyInfo> list = dbOper.Query<CompanyInfo>(sql, companyLoginName);
            if (list.Count > 0)
            {
                return list.First();
            }
            else
            {
                return null;
            }
        }
    }
}
